package com.sos.data.adapters
{
	import com.sos.config.Configuration;

	public class ConfigurationAdapter
	{
		public static function fromXML(xml:XML):Configuration
		{
			// Create new configurtion
			var config:Configuration = new Configuration();
			// Safe exec
			try
			{
				// URLs
				config.serverUrl 	= xml.serverUrl;
				config.callsUrl 	= xml.callsUrl;
				config.imagesUrl 	= xml.imagesUrl;
				// DebugOptions
				config.debugOptions = DebugOptionsAdapter.fromXML(xml.debugOptions[0]);
				// GameOptions
				config.gameOptions	= GameOptionsAdapter.fromXML(xml.gameOptions[0]);
				// Log options
				config.logOptions	= LogOptionsAdapter.fromXML(xml.logOptions[0]);
			}
			// Unexpected exception
			catch (e:Error)
			{
				throw new Error("ConfigurationAdapter.fromXML() unexpected error: " + e.toString());
			}
			return config;
		}
	}
}